package com.latam.arq.example.events.ejb.impl;

import javax.ejb.Stateless;
import javax.interceptor.Interceptors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.latam.arq.commons.events.annotations.BusinessEvent;
import com.latam.arq.commons.events.interceptor.BusinessEventPublisherInterceptor;
import com.latam.arq.commons.exceptions.LATAMException;
import com.latam.arq.example.events.ejb.services.ExampleEventSenderService;

@Stateless(
		mappedName="ejb/ExampleEventSender",
		description="EJB for wrapping the send event framework.",
		name = "ExampleEventSenderEJB")
public class ExampleEventSenderImpl implements ExampleEventSenderService{
	private static final Logger logger = LoggerFactory.getLogger(ExampleEventSenderImpl.class);
	
	@Override
	@Interceptors({BusinessEventPublisherInterceptor.class})
	@BusinessEvent(eventName="HelloEvent")	
	public String hello(String message) throws LATAMException {
		if (logger.isInfoEnabled()){
			logger.info("Execution of Hello method!.");
		}
		return "Execution of hello with \"" + message + "\"";
	}
}